package Demoo;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class Demo2 {

    private Socket socket = null;

    public Demo2(String p1, int p2) throws IOException {
        socket = new Socket(p1, p2);
    }

    public void start() {
        try (InputStream inputStream = socket.getInputStream();
             OutputStream outputStream = socket.getOutputStream()) {
            Scanner sc = new Scanner(inputStream);
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner scanner = new Scanner(System.in);
            while (true) {

                String s1 = scanner.next();
                printWriter.println(s1);
                printWriter.flush();
                String s2 = sc.next();
                System.out.println(s2);
            }
        } catch (IOException e) {

            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) throws IOException {
        Demo2 d = new Demo2("127.0.0.1", 9099);
        d.start();
    }
}
